<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Ads extends CI_Controller
{
	private $ads_conf = array();
	function __construct()
	{
		parent::__construct();
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		$this->load->library('tank_auth');
		$this->config->load('ads_generate', TRUE);
	}

	function index()
	{
		if (!$this->tank_auth->is_logged_in()) {
			redirect('/auth/login/');
		} else {
			$data['user_id']	= $this->tank_auth->get_user_id();
			$data['username']	= $this->tank_auth->get_username();
			$this->load->view('welcome', $data);
		}
	}
	
	/**
	 * Change user password
	 *
	 * @return void
	 */
	function input_ads_feature(){
		if (!$this->tank_auth->is_logged_in()) {								// not logged in or not activated
			redirect('/auth/login/');
		}
		else{
			$this->load->view('adsense/ads_feature_input');
		}
	}
	
	function initial_ads(){ // initial ads by user inputs
		
		if (!$this->tank_auth->is_logged_in()) {								// not logged in or not activated
			redirect('/auth/login/');
		}
		else{
			$data = array();
			$initial_terms = $this->config->item('initial_terms', 'ads_generate');
			$initial_terms_rule = $this->config->item('initial_terms_rule', 'ads_generate');
			
			$this->form_validation->set_rules($initial_terms_rule);
			
			if ($this->form_validation->run()) {
				$data = array(
					'param_type'=>$this->form_validation->set_value('param_type'),
					'title_color'=>$this->form_validation->set_value('title_color'),
					'desc_color'=>$this->form_validation->set_value('desc_color'),
					'url_color'=>$this->form_validation->set_value('url_color'),
					'container_w'=>$this->form_validation->set_value('container_w'),
					'container_h'=>$this->form_validation->set_value('container_h'),
					'container_border_c'=>$this->form_validation->set_value('container_border_c'),
					'container_background_c'=>$this->form_validation->set_value('container_background_c'),
					'ysmlabel_color'=>$this->form_validation->set_value('ysmlabel_color'),
					'title_fontsize'=>$this->form_validation->set_value('title_fontsize'),
					'desc_fontsize'=>$this->form_validation->set_value('desc_fontsize'),
					'url_fontsize'=>$this->form_validation->set_value('url_fontsize'),
					'css'=>$this->form_validation->set_value('css')
				);
			}
			else{
				
				$this->load->view('adsense/ads_feature_input');
			}
			
			
			$this->load->view('adsense/generate_ads',$data);
		}
		
		
		
	}
	
	function generate_ads(){
		
		if (!$this->tank_auth->is_logged_in()) {								// not logged in or not activated
			redirect('/auth/login/');
		}
		else{
			
		}
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */